from ij import IJ, WindowManager 
from java.awt.event import MouseAdapter
from ij.gui import Roi

def doSomething(imp,canvas):
	p = canvas.getCursorLoc()
	x = int(p.x)
	y = int(p.y)
	print x,' ',y   
	ip = imp.getProcessor()
	roi = Roi(x, y, 10, 10)  
	ip.setRoi(roi)  
	ip.setValue(255)  
	ip.fill()  
	imp.updateAndDraw()
	
class ML(MouseAdapter):
	def mousePressed(self, event):
		canvas = event.getSource()
		imp = canvas.getImage()
		doSomething(imp,canvas)
 
listener = ML()
IJ.runPlugIn("ij.plugin.Zoom","scale")

for imp in map(WindowManager.getImage, WindowManager.getIDList()):
	win = imp.getWindow()
	if win is None:
		continue
	win.getCanvas().addMouseListener(listener)